import { IsString, IsNumber, IsBoolean, IsDate, IsOptional, IsEnum, IsArray } from 'class-validator';
import { ApiProperty, OmitType, IntersectionType } from '@nestjs/swagger';
import { PagingDto } from 'src/common/dto/index';
import { CharEnum } from 'src/common/enum/index';
import { Type } from 'class-transformer';

export class BaseRecordDto {
  @ApiProperty({ required: false, description: '记录ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  id?: number;

  @ApiProperty({ required: false, description: '订单ID' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  orderId?: number;

  @ApiProperty({ required: false, description: '订单编号' })
  @IsOptional()
  @IsString()
  orderNo?: string;

  @ApiProperty({ required: false, description: '商户订单号' })
  @IsOptional()
  @IsString()
  outTradeNo?: string;

  @ApiProperty({ required: false, description: '微信支付订单号' })
  @IsOptional()
  @IsString()
  transactionId?: string;

  @ApiProperty({ required: false, description: '商户退款单号' })
  @IsOptional()
  @IsString()
  outRefundNo?: string;

  @ApiProperty({ required: false, description: '微信退款单号' })
  @IsOptional()
  @IsString()
  refundId?: string;

  @ApiProperty({ required: false, description: '退款金额(分)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  refundFee?: number;

  @ApiProperty({ required: false, description: '订单总金额(分)' })
  @IsOptional()
  @IsNumber()
  @Type(() => Number)
  totalFee?: number;

  @ApiProperty({ required: false, description: '退款状态' })
  @IsOptional()
  @IsString()
  refundStatus?: string;

  @ApiProperty({ required: false, description: '退款原因' })
  @IsOptional()
  @IsString()
  refundDesc?: string;

  @ApiProperty({ required: false, description: '退款成功时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  refundSuccessTime?: Array<string>;

  @ApiProperty({ required: false, description: '创建时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  createTime?: Array<string>;

  @ApiProperty({ required: false, description: '更新时间' })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  updateTime?: Array<string>;
}

export class CreateRecordDto extends OmitType(BaseRecordDto, ['id', 'createTime']) {}

export class UpdateRecordDto extends OmitType(BaseRecordDto, ['createTime']) {}

export class QueryRecordDto extends IntersectionType(BaseRecordDto, PagingDto) {}

export class ListRecordDto extends OmitType(BaseRecordDto, ['createTime', 'updateTime']) {}
